﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace AgentAssignment
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public Agents AgentsList;

        public MainWindow()
        {
            InitializeComponent();
        }

        private void WindowLoaded(object sender, RoutedEventArgs e)
        {
            AgentsList = new Agents();
            this.DataContext = AgentsList;
        }

        private void AddButtonClick1(object sender, RoutedEventArgs e)
        {
            AgentsList.Add(new Agent("None", "None", "None", "None"));
        }

        private void DeleteButtonClick1(object sender, RoutedEventArgs e)
        {
            AgentsList.Remove(AgentsListBox.SelectedItem as Agent);
        }

        private void PrevButtonClick1(object sender, RoutedEventArgs e)
        {
            AgentsListBox.SelectedIndex = (AgentsListBox.SelectedIndex - 1) >= 0 ? (AgentsListBox.SelectedIndex - 1) : 0;
        }

        private void NextButtonClick1(object sender, RoutedEventArgs e)
        {
            AgentsListBox.SelectedIndex = AgentsListBox.SelectedIndex + 1;
        }

        private void ExitClicked(object sender, RoutedEventArgs e)
        {
            Application.Current.Shutdown(0);
        }
    }
}
